<template>
  <div>
    <button @click="isShow = true">点我弹个窗</button>
    <!-- teleport:传送   to="html" 传送到html中去   to="body" 传送到body中去 -->
    <!-- 此处的to="#afanfan" 在public里的index.html里有<div id="afanfan"></div> -->
    <teleport to="#afanfan">
      <div v-if="isShow" class="mask">
        <div class="dialogStyle">
          <h3>我是一个弹窗</h3>
          <h4>一些内容</h4>
          <h4>一些内容</h4>
          <h4>一些内容</h4>
          <button @click="isShow = false">关闭弹窗</button>
        </div>
      </div>
    </teleport>
  </div>
</template>

<script>
import { ref } from "vue";
export default {
  name: "dialog",
  setup() {
    let isShow = ref(false);
    return {
      isShow,
    };
  },
};
</script>

<style>
.mask {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgb(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.dialogStyle {
  width: 300px;
  height: 300px;
  background-color: green;
}
</style>